/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef LITTLEBIGENDIANCONVERTER_H
#define LITTLEBIGENDIANCONVERTER_H

//little endian - Intel, big endian - Mac

namespace endianess
{

inline float get_type_le( float f )
{ 
	unsigned char* buf = (unsigned char*)&f;
	int val = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
	return *(float*)&val;
}

inline short int get_type_le( short int f )
{
	unsigned char* buf = (unsigned char*)&f;
	return (short int) buf[0] | (buf[1] << 8);
}

inline unsigned short int get_type_le( unsigned short int f )
{
	unsigned char* buf = (unsigned char*)&f;
	return (unsigned short int) buf[0] | (buf[1] << 8);
}

inline int get_type_le( int f )
{
	unsigned char* buf = (unsigned char*)&f;
	return (int) buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}

inline unsigned int get_type_le( unsigned int f )
{
	unsigned char* buf = (unsigned char*)&f;
	return (unsigned int) buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}

} //namespace endianess

#endif //LITTLEBIGENDIANCONVERTER_H